/*
 * @Description:输出
 * 
 * @Author: rendc
 * 
 * @Date: 2025-08-20 10:28:54
 * 
 * @LastEditors: rendc
 * 
 * @LastEditTime: 2025-08-20 11:26:23
 */
public class MyPrint {

  // 普通同步方法
  public synchronized void print1() {
    System.out.print("天");
    System.out.print("天");
    System.out.print("向");
    System.out.print("上");
    System.out.print("\n");
  }

  // 静态同步方法
  public static synchronized void print3() {
    System.out.print("天");
    System.out.print("天");
    System.out.print("向");
    System.out.print("上");
    System.out.print("\n");
  }

  // 同步代码块
  public void print2() {
    try {
      this.wait();
    } catch (Exception e) {
      e.printStackTrace();
    }

    synchronized (this) {
      // try {
      // this.wait();
      // } catch (Exception e) {
      // e.printStackTrace();
      // }
      // synchronized (MyPrint.class) {
      System.out.print("好");
      System.out.print("好");
      System.out.print("学");
      System.out.print("习");
      System.out.print("\n");
    }
  }

}